//
//  CustomOrderInfoViewController.m
//  AmountBody
//
//  Created by Qiu Jishuai on 2018/1/13.
//  Copyright © 2018年 RCMTM. All rights reserved.
//

#import "CustomOrderInfoViewController.h"
#import "CustomContainerView.h"
#import <AmountBody-Swift.h>
#import "OrderInfo.h"

@interface CustomOrderInfoViewController()<InfoListViewDatasource>
@property (nonatomic, strong) InfoListView *infoListView;
@property (nonatomic, strong) NSArray<OrderInfo *> *infos;
@end
@implementation CustomOrderInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.rightContainerView.backgroundImage = [UIImage imageNamed:@"custom_custom_info"];
    self.infoListView = [[InfoListView alloc] init];
    _infoListView.datasource = self;
    [self.rightContainerView.container addSubview:_infoListView];

    OrderInfo *info = [OrderInfo new];
    info.title = @"尺寸信息";
    self.infos = @[[OrderInfo new]];//, info];
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];

    UIView *container = self.rightContainerView.container;
    [_infoListView mas_remakeConstraints:^(MASConstraintMaker *make) {
        layoutViews(^{ //横屏
            make.edges.equalTo(container).insets(UIEdgeInsetsMake(50, 32, 25, 30));
        }, ^{ //竖屏
            make.edges.equalTo(container).insets(UIEdgeInsetsMake(55, 30, 26, 30));
        });
    }];
}

- (UITableViewCell *)listView:(InfoListView *)listVeiw cellForRowAt:(NSIndexPath *)indexPath {
    InfoListFormCell *cell = [listVeiw.tableView dequeueReusableCellWithIdentifier:@"InfoListFormCell" forIndexPath:indexPath];
    return cell;
}

- (NSArray<NSString *> *)listView:(InfoListView *)listView headerTextsInSection:(NSInteger)section {
    OrderInfo *info = _infos[section];
    NSString *title = info.title;
    if (!title.length) {
        title = @"";
    }
    NSString *subtitle = info.detail;
    if (!subtitle.length) {
        subtitle = @"";
    }
    return @[title, subtitle];
}

- (NSInteger)numberOfSectionsIn:(InfoListView *)listView {
    return _infos.count;
}

@end
